package com.threeox.commonlibrary.entity.engine.request.sharedpre;


import android.content.Context;

import com.threeox.commonlibrary.entity.engine.request.base.BaseRequestMsg;
import com.threeox.utillibrary.util.res.StringHelper;

/**
 *
 * @ClassName: SharedPreReqMsg
 *
 * @Description: TODO(SharedPreferences请求操作)
 *
 * @author 赵屈犇
 *
 * @date 创建时间: 2017/7/4 12:43
 *
 * @version 1.0
 *
 */
public class SharedPreReqMsg extends BaseRequestMsg {

    private String name; //本地存放的名称
    private String key; //存放数据的键值
    private int preferencesMode;// 数据存储的Mode
    private OperationTypeMsg operationType;// 操作的类型
    private SharedPreferencesMode mode;// 数据存储的操作模式

    public void initData(StringHelper stringHelper) {
        this.key = stringHelper.getStringText(key);
        this.name = stringHelper.getStringText(name);
        if (mode != null)
            mode = SharedPreferencesMode.MODE_PRIVATE;
        if (mode == SharedPreferencesMode.MODE_PRIVATE) {
            preferencesMode = Context.MODE_PRIVATE;
        } else if (mode == SharedPreferencesMode.MODE_APPEND) {
            preferencesMode = Context.MODE_APPEND;
        } else if (mode == SharedPreferencesMode.MODE_WORLD_READABLE) {
            preferencesMode = Context.MODE_WORLD_READABLE;
        } else if (mode == SharedPreferencesMode.MODE_WORLD_WRITEABLE) {
            preferencesMode = Context.MODE_WORLD_WRITEABLE;
        }
        super.initData(stringHelper, key);
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String getKey() {
        return key;
    }

    @Override
    public void setKey(String key) {
        this.key = key;
    }

    public OperationTypeMsg getOperationType() {
        return operationType;
    }

    public void setOperationType(OperationTypeMsg operationType) {
        this.operationType = operationType;
    }

    public SharedPreferencesMode getMode() {
        return mode;
    }

    public void setMode(SharedPreferencesMode mode) {
        this.mode = mode;
    }

    public int getPreferencesMode() {
        return preferencesMode;
    }

    public void setPreferencesMode(int preferencesMode) {
        this.preferencesMode = preferencesMode;
    }
}
